import API from "../../library/axios/api";
export function getSongData(item) {
    API.album.dynamic({ id: 140451319 }).then(res => {
        this.bookedCount = res.likedCount;
        this.shareCount = res.shareCount;
        this.playCount = res.subCount;
        this.commentCount = res.commentCount;
        localStorage.setItem('playlistCount', JSON.stringify(res));
    });
    API.playlist.detail({ id: item.targetId }).then(res => {
        console.log(res);
        localStorage.setItem('playlistData', JSON.stringify(res.playlist));
    })
    if (item.targetType === 10) {
        API.album.album({ id: item.targetId }).then(res => {
            console.log(res);
            this.songs = res.songs;
            this.playlistName = res.album.name;
            this.coverImgUrl = res.album.blurPicUrl;
            this.createTime = res.album.publishTime;
            this.playlistType = res.album.type;
            this.description = res.album.description;
            this.avatar = res.album.artist.picUrl;
            this.authorName = res.album.artist.name;
            localStorage.setItem('album', JSON.stringify(res.album));
            localStorage.setItem('songs', JSON.stringify(res.songs));
        })
    } else {
        API.playlist.track({ id: item.targetId }).then(res => {
            this.songs = res.songs
            localStorage.setItem('songs', JSON.stringify(res.songs));
        })
    }

}
export function playSong(id) {
    this.$bus.$emit("songId", id);
    API.song.url({ id }).then((res) => {
        this.$store.commit('songData/getSongUrl', res.data[0].url);
    });
}